package cn.lg.soar.system.biz.modules.tenant.service.impl;

import cn.lg.soar.core.dto.UserBaseInfo;
import cn.lg.soar.system.biz.modules.auth.entity.User;
import cn.lg.soar.system.biz.modules.auth.service.IUserService;
import cn.lg.soar.system.biz.modules.tenant.entity.TenantUser;
import cn.lg.soar.system.biz.modules.tenant.mapper.TenantUserMapper;
import cn.lg.soar.system.biz.modules.tenant.service.ITenantUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * TenantUser服务层实现
 * 租户用户
 * @author luguoxiang
 * @since 2022-04-30
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public class TenantUserServiceImpl extends ServiceImpl<TenantUserMapper, TenantUser> implements ITenantUserService {

    @Autowired
    private IUserService userService;

    @Override
    public UserBaseInfo getUser(String code) {
        User user = userService.getByUsername(code);
        if (user == null) {
            return null;
        }
        UserBaseInfo userBaseInfo = new UserBaseInfo();
        userBaseInfo.setUserId(user.getId());
        userBaseInfo.setUserCode(user.getUsername());
        userBaseInfo.setUserName(user.getNickname());
        userBaseInfo.setUserAvatar(user.getAvatar());
        return userBaseInfo;
    }

}
